package com.neusoft.work.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.neusoft.work.dto.BedAssignmentDTO;
import com.neusoft.work.po.BedAssignment;
import com.neusoft.work.po.PageResponseBean;
import com.neusoft.work.po.ResponseBean;
import com.neusoft.work.service.BedAssignmentService;


@RequestMapping("/BedAssignmentController")
@RestController
public class BedAssignmentController {
    @Autowired
    private BedAssignmentService bas;

    @RequestMapping("/addBedAssignment")
    public ResponseBean<Integer> addBedAssignment(BedAssignment bs) {
        return bas.addBedAssignment(bs);
    }

    @RequestMapping("/deleteBedAssignment")
    public ResponseBean<Integer> deleteBedAssignment(Integer id){
        return bas.deleteBedAssignment(id);
    }

    @RequestMapping("/updateBedAssignment")
    public ResponseBean<Integer> updateBedAssignment(BedAssignment bs){
        return bas.updateBedAssignment(bs);
    }

    @RequestMapping("/queryBedAssignmentByCondition")
    public PageResponseBean<List<BedAssignmentDTO>> queryBedAssignmentInUse(String name, String assignStartTimeBegin, String assignStartTimeEnd, Boolean isDeleted, Long cur, Long number){
        return bas.queryBedAssignmentInUse(name, assignStartTimeBegin, assignStartTimeEnd, isDeleted, cur, number);
    }

    
    @PostMapping("/deleteByCustomer")
    public ResponseBean<Integer> deleteByCustomer(Integer customerId) {
      return bas.deleteByCustomer(customerId);
    }

    @PostMapping("/updateEndTimeByCustomer")
    public ResponseBean<Integer> updateEndTimeByCustomer(Integer customerId, String assignEndTime) {
      return bas.updateEndTimeByCustomer(customerId, assignEndTime);
    }
    
    // 床位调换接口
    @PostMapping("/swapBed")
    public ResponseBean<String> swapBed(Integer customerId, String newBedNumber) {
        return bas.swapBed(customerId, newBedNumber);
    }
}
